/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import java.sql.Date;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import projetobancodedados.*;

/**
 *
 * @author Christian
 */
public class mainScreen extends javax.swing.JFrame {

    /**
     * Creates new form mainScreen
     */
    public mainScreen() {
        this.setTitle("Projeto BD");
        this.setResizable(false);
        initComponents();
        professorControle prfControl = new professorControle();
        professores = prfControl.listaProfessores();
        for(int i=0; i<professores.size();i++)
        {
            jComboBox1.addItem(professores.get(i).getNome());
        }
        prfControl.closeConnection();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel6 = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        alnPanel = new javax.swing.JPanel();
        labelDocumentoAluno = new javax.swing.JLabel();
        labelLdPesquisa = new javax.swing.JLabel();
        labelNomeAluno = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        aluDiscField = new javax.swing.JTextField();
        pqalunoField = new javax.swing.JTextField();
        alunoField = new javax.swing.JTextField();
        doc_alunoField = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        jLabel17 = new javax.swing.JLabel();
        docprfField = new javax.swing.JTextField();
        listaAln = new javax.swing.JButton();
        prfPanel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        nomeField = new javax.swing.JTextField();
        cursoField = new javax.swing.JTextField();
        discField = new javax.swing.JTextField();
        pesquisaField = new javax.swing.JTextField();
        docField = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        listaProf = new javax.swing.JButton();
        dscPanel = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jTextField5 = new javax.swing.JTextField();
        jTextField6 = new javax.swing.JTextField();
        jTextField7 = new javax.swing.JTextField();
        jComboBox1 = new javax.swing.JComboBox();
        cadastraDisciplina = new javax.swing.JButton();
        listDisc = new javax.swing.JButton();
        defPanel = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        codDefesa = new javax.swing.JTextField();
        alnDefesa = new javax.swing.JTextField();
        prfDefesa = new javax.swing.JTextField();
        tituloDefesa = new javax.swing.JTextField();
        jButton4 = new javax.swing.JButton();
        dataDefesa = new javax.swing.JFormattedTextField();
        listarBtn = new javax.swing.JButton();

        jLabel6.setText("jLabel6");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        labelDocumentoAluno.setText("Documento:");

        labelLdPesquisa.setText("Linha de Pesquisa:");

        labelNomeAluno.setText("Nome:");

        jLabel7.setText("Documento do Professor:");

        jButton2.setText("Cadastrar Aluno");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel17.setText("Disciplina:");

        listaAln.setText("Listar Alunos");
        listaAln.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listaAlnActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout alnPanelLayout = new javax.swing.GroupLayout(alnPanel);
        alnPanel.setLayout(alnPanelLayout);
        alnPanelLayout.setHorizontalGroup(
            alnPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(alnPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(alnPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(listaAln)
                    .addGroup(alnPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(alnPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jButton2)
                            .addGroup(alnPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(alnPanelLayout.createSequentialGroup()
                                    .addComponent(labelNomeAluno)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(doc_alunoField))
                                .addGroup(alnPanelLayout.createSequentialGroup()
                                    .addComponent(labelLdPesquisa)
                                    .addGap(27, 27, 27)
                                    .addComponent(pqalunoField, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE))
                                .addGroup(alnPanelLayout.createSequentialGroup()
                                    .addComponent(jLabel7)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(docprfField))
                                .addGroup(alnPanelLayout.createSequentialGroup()
                                    .addComponent(labelDocumentoAluno)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(alunoField))))
                        .addGroup(alnPanelLayout.createSequentialGroup()
                            .addComponent(jLabel17)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(aluDiscField))))
                .addGap(0, 135, Short.MAX_VALUE))
        );
        alnPanelLayout.setVerticalGroup(
            alnPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(alnPanelLayout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(alnPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(alunoField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelDocumentoAluno))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(alnPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(doc_alunoField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelNomeAluno))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(alnPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labelLdPesquisa)
                    .addComponent(pqalunoField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(alnPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(docprfField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(alnPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(aluDiscField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(9, 9, 9)
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(listaAln)
                .addContainerGap(62, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("ALUNOS", alnPanel);

        jLabel1.setText("Nome:");

        jLabel2.setText("Curso:");

        jLabel3.setText("Disciplina Lecionada:");

        jLabel4.setText("Linha de Pesquisa:");

        jLabel5.setText("CPF:");

        jButton1.setText("Cadastrar Professor");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        listaProf.setText("Listar Professores");
        listaProf.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listaProfActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout prfPanelLayout = new javax.swing.GroupLayout(prfPanel);
        prfPanel.setLayout(prfPanelLayout);
        prfPanelLayout.setHorizontalGroup(
            prfPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(prfPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(prfPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(listaProf)
                    .addComponent(jButton1)
                    .addGroup(prfPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(prfPanelLayout.createSequentialGroup()
                            .addComponent(jLabel1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(nomeField, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(prfPanelLayout.createSequentialGroup()
                            .addComponent(jLabel2)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(cursoField))
                        .addGroup(prfPanelLayout.createSequentialGroup()
                            .addComponent(jLabel3)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(discField))
                        .addGroup(prfPanelLayout.createSequentialGroup()
                            .addComponent(jLabel4)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(pesquisaField))
                        .addGroup(prfPanelLayout.createSequentialGroup()
                            .addComponent(jLabel5)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(docField))))
                .addContainerGap(189, Short.MAX_VALUE))
        );
        prfPanelLayout.setVerticalGroup(
            prfPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(prfPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(prfPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(nomeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(prfPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(cursoField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(prfPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(discField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(prfPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(pesquisaField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(prfPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(docField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(listaProf)
                .addContainerGap(79, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("PROFESSORES", prfPanel);

        jLabel8.setText("Código da Disciplina:");

        jLabel9.setText("Nome da Disciplina:");

        jLabel10.setText("Curso:");

        jLabel11.setText("Professor:");

        cadastraDisciplina.setText("Cadastrar Disciplina");
        cadastraDisciplina.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cadastraDisciplinaActionPerformed(evt);
            }
        });

        listDisc.setText("Listar Disciplinas");
        listDisc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listDiscActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout dscPanelLayout = new javax.swing.GroupLayout(dscPanel);
        dscPanel.setLayout(dscPanelLayout);
        dscPanelLayout.setHorizontalGroup(
            dscPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dscPanelLayout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(dscPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(listDisc)
                    .addComponent(cadastraDisciplina)
                    .addGroup(dscPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(dscPanelLayout.createSequentialGroup()
                            .addComponent(jLabel8)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jTextField5))
                        .addGroup(dscPanelLayout.createSequentialGroup()
                            .addComponent(jLabel9)
                            .addGap(2, 2, 2)
                            .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(dscPanelLayout.createSequentialGroup()
                            .addComponent(jLabel11)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(dscPanelLayout.createSequentialGroup()
                            .addComponent(jLabel10)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jTextField7))))
                .addContainerGap(117, Short.MAX_VALUE))
        );
        dscPanelLayout.setVerticalGroup(
            dscPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dscPanelLayout.createSequentialGroup()
                .addGap(16, 16, 16)
                .addGroup(dscPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(dscPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(dscPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(dscPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(cadastraDisciplina)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(listDisc)
                .addContainerGap(73, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("DISCIPLINAS", dscPanel);

        jLabel12.setText("Codigo da Defesa:");

        jLabel13.setText("Documento do Aluno:");

        jLabel14.setText("Documento do Professor:");

        jLabel15.setText("Data:");

        jLabel16.setText("Titulo da Defesa:");

        jButton4.setText("Cadastrar Defesa");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        dataDefesa.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("yyyy/MM/dd"))));

        listarBtn.setText("Listar Defesas Cadastradas");
        listarBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listarBtnActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout defPanelLayout = new javax.swing.GroupLayout(defPanel);
        defPanel.setLayout(defPanelLayout);
        defPanelLayout.setHorizontalGroup(
            defPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(defPanelLayout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addGroup(defPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(listarBtn)
                    .addComponent(jButton4)
                    .addGroup(defPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(defPanelLayout.createSequentialGroup()
                            .addComponent(jLabel16)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(tituloDefesa))
                        .addGroup(defPanelLayout.createSequentialGroup()
                            .addComponent(jLabel13)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(alnDefesa))
                        .addGroup(defPanelLayout.createSequentialGroup()
                            .addComponent(jLabel12)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(codDefesa, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(defPanelLayout.createSequentialGroup()
                            .addGroup(defPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(defPanelLayout.createSequentialGroup()
                                    .addComponent(jLabel15)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(dataDefesa))
                                .addComponent(jLabel14))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(prfDefesa))))
                .addContainerGap(64, Short.MAX_VALUE))
        );
        defPanelLayout.setVerticalGroup(
            defPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(defPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(defPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(codDefesa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(defPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(alnDefesa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(defPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(prfDefesa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(defPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(dataDefesa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(defPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(tituloDefesa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jButton4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(listarBtn)
                .addContainerGap(57, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("DEFESAS", defPanel);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.TRAILING)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1)
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-416)/2, (screenSize.height-338)/2, 416, 338);
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        if ((docField.getText().equalsIgnoreCase("")) || (nomeField.getText().equalsIgnoreCase("")) || (cursoField.getText().equalsIgnoreCase("")) || (discField.getText().equalsIgnoreCase("")) || (pesquisaField.getText().equalsIgnoreCase(""))) {
            JOptionPane.showMessageDialog(rootPane, "É Necessário preencher todos os campos!", "ERRO", JOptionPane.ERROR_MESSAGE);
        } else {
            System.out.println("continua com o salvamento");

            String id = docField.getText();
            String nome = nomeField.getText();
            String curso = cursoField.getText();
            String disc = discField.getText();
            String pesquisa = pesquisaField.getText();

            professor prf = new professor(id, nome, curso, disc, pesquisa);
            professorControle prfControl = new professorControle();
            professores.add(prf);
            

            prfControl.addProfessor(prf);
            prfControl.closeConnection();
            
            jComboBox1.addItem(professores.get(professores.size()-1).getNome());

            docField.setText("");
            nomeField.setText("");
            cursoField.setText("");
            discField.setText("");
            pesquisaField.setText("");
            JOptionPane.showMessageDialog(null, "Cadastrado com Sucesso");
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        if ((alunoField.getText().equalsIgnoreCase("")) || (doc_alunoField.getText().equalsIgnoreCase("")) || (pqalunoField.getText().equalsIgnoreCase("")) || (aluDiscField.getText().equalsIgnoreCase(""))) {
            JOptionPane.showMessageDialog(rootPane, "É Necessário preencher todos os campos!", "ERRO", JOptionPane.ERROR_MESSAGE);
        } else {
            System.out.println("continua com o salvamento");
            
            String doc_aluno = alunoField.getText();
            String nome = doc_alunoField.getText();
            String doc_prof = docprfField.getText();            
            String pesquisa = pqalunoField.getText();
            String disc = aluDiscField.getText();

            Aluno alu = new Aluno(doc_aluno, nome, doc_prof, disc, pesquisa);
            AlunoControle aluControl = new AlunoControle();

            aluControl.addAluno(alu);
            aluControl.closeConnection();

            alunoField.setText("");
            doc_alunoField.setText("");
            pqalunoField.setText("");
            aluDiscField.setText("");
            docprfField.setText("");
            JOptionPane.showMessageDialog(null, "Cadastrado com Sucesso");
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void cadastraDisciplinaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cadastraDisciplinaActionPerformed
        if ((jTextField5.getText().equalsIgnoreCase("")) || (jTextField6.getText().equalsIgnoreCase("")) || (jTextField7.getText().equalsIgnoreCase("")) || (jComboBox1.getSelectedItem().toString().equalsIgnoreCase(""))) {
            JOptionPane.showMessageDialog(rootPane, "É Necessário preencher todos os campos!", "ERRO", JOptionPane.ERROR_MESSAGE);
        } else {
            System.out.println("continua com o salvamento");
            
            String cod_disc = jTextField5.getText();
            String nome = jTextField6.getText();
            String curso = jTextField7.getText();            
            String doc_prof = "";
            
            for(int i = 0; i<professores.size(); i++)
            {
                if(professores.get(i).getNome().equalsIgnoreCase(jComboBox1.getSelectedItem().toString())){
                    doc_prof = professores.get(i).getID();
                }else{
                    System.out.println("Erro!");
                }
            }

            Disciplina disc = new Disciplina(cod_disc, nome, curso, doc_prof);
            DisciplinaControle discControl = new DisciplinaControle();
            discControl.addDisciplina(disc);
            discControl.closeConnection();

            jTextField5.setText("");
            jTextField6.setText("");
            jTextField7.setText("");
           
            JOptionPane.showMessageDialog(null, "Cadastrado com Sucesso");
        }
    }//GEN-LAST:event_cadastraDisciplinaActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
       if ((codDefesa.getText().equalsIgnoreCase("")) || (alnDefesa.getText().equalsIgnoreCase("")) || (prfDefesa.getText().equalsIgnoreCase("")) || (tituloDefesa.getText().equalsIgnoreCase(""))|| (dataDefesa.getText().equalsIgnoreCase(""))) {
            JOptionPane.showMessageDialog(rootPane, "É Necessário preencher todos os campos!", "ERRO", JOptionPane.ERROR_MESSAGE);
        } else {
            try {
                System.out.println("continua com o salvamento");
                int cod_def = Integer.parseInt(codDefesa.getText());
                String aluno = alnDefesa.getText();
                String prof = prfDefesa.getText();
                DateFormat df = new SimpleDateFormat("yyy/MM/dd");
                java.sql.Date data = new java.sql.Date(df.parse(dataDefesa.getText()).getTime());
                String titulo = tituloDefesa.getText();
                
                Defesa def = new Defesa(cod_def, aluno, prof, data, titulo);
                DefesaControle defControl = new DefesaControle();
                defControl.addDefesa(def);
                defControl.closeConnection();
                
                codDefesa.setText("");
                alnDefesa.setText("");
                prfDefesa.setText("");
                dataDefesa.setText("");
                tituloDefesa.setText("");
                JOptionPane.showMessageDialog(null, "Cadastrado com Sucesso");
            } catch (ParseException ex) {
                ex.printStackTrace();
            }
        }
    }//GEN-LAST:event_jButton4ActionPerformed

    private void listarBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listarBtnActionPerformed
        listaDefesas lista = new listaDefesas();
        lista.setVisible(true);
    }//GEN-LAST:event_listarBtnActionPerformed

    private void listDiscActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listDiscActionPerformed
        listaDisc lista = new listaDisc();
        lista.setVisible(true);
    }//GEN-LAST:event_listDiscActionPerformed

    private void listaProfActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listaProfActionPerformed
        listaProf lista = new listaProf();
        lista.setVisible(true);
    }//GEN-LAST:event_listaProfActionPerformed

    private void listaAlnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listaAlnActionPerformed
        listaAlunos lista = new listaAlunos();
        lista.setVisible(true);
    }//GEN-LAST:event_listaAlnActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(mainScreen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(mainScreen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(mainScreen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(mainScreen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new mainScreen().setVisible(true);
            }
        });
    }
    private ArrayList<professor> professores;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField alnDefesa;
    private javax.swing.JPanel alnPanel;
    private javax.swing.JTextField aluDiscField;
    private javax.swing.JTextField alunoField;
    private javax.swing.JButton cadastraDisciplina;
    private javax.swing.JTextField codDefesa;
    private javax.swing.JTextField cursoField;
    private javax.swing.JFormattedTextField dataDefesa;
    private javax.swing.JPanel defPanel;
    private javax.swing.JTextField discField;
    private javax.swing.JTextField docField;
    private javax.swing.JTextField doc_alunoField;
    private javax.swing.JTextField docprfField;
    private javax.swing.JPanel dscPanel;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton4;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
    private javax.swing.JLabel labelDocumentoAluno;
    private javax.swing.JLabel labelLdPesquisa;
    private javax.swing.JLabel labelNomeAluno;
    private javax.swing.JButton listDisc;
    private javax.swing.JButton listaAln;
    private javax.swing.JButton listaProf;
    private javax.swing.JButton listarBtn;
    private javax.swing.JTextField nomeField;
    private javax.swing.JTextField pesquisaField;
    private javax.swing.JTextField pqalunoField;
    private javax.swing.JTextField prfDefesa;
    private javax.swing.JPanel prfPanel;
    private javax.swing.JTextField tituloDefesa;
    // End of variables declaration//GEN-END:variables
}
